package com.wk.springbootlearn;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@Slf4j
@SpringBootApplication
@MapperScan("com.wk.springbootlearn.mapper")
public class SpringBootLearnApplication implements CommandLineRunner {

	@Autowired
	private DataSource dataSource;

	public static void main(String[] args) {
		SpringApplication.run(SpringBootLearnApplication.class, args);
	}

	@Override
	public void run(String... args) {
		try (Connection conn = dataSource.getConnection()) {
			log.info("[run][获得连接:{}]",conn);
		}catch (SQLException e) {
			throw new RuntimeException(e);
		}
	}
}
